<template>
	<view class="content unify-relative">
		<!-- 顶部背景 -->
		<view class="user-top unify-absolute" :class="'bg-' + themeColor.name">
			<image class="user-bg" :src="userBg" mode=""></image>
		</view>
		<!-- 间隔 -->
		<view style="height: 135px"></view>
		
		<!-- 用户信息 -->
		<view class="user-info unify-margin unify-background-color unify-relative unify-radius unify-flex unify-padding">
			<view class="user-name">
				{{userInfo.nickName}}
				<view class="user-phone">{{userInfo.phone}}</view>
			</view>
			<image class="user-image" :src="userInfo.avatarUrl" mode=""></image>
		</view>
		
		
		
		<!-- 用户操作菜单 -->
		<view class="user-operation-menu unify-background-color unify-radius unify-margin unify-padding">
			<view class="user-operation-menu-item unify-flex" v-for="(item,index) in userOperationMenu" :key="index" @tap="tapOperation(item.url)">
				<view class="left unify-flex">
					<view class="iconfont" :class="item.icon"></view>
					<view class="unify-weight">{{item.name}}</view>
				</view>
				<view class="right iconfont el-icon-icon12 unify-rotate90"></view>
			</view>
		</view>
		


		
		
	</view>
</template>

<script>
	import { mapState } from 'vuex';
	export default {
		data() {
			return {
				iconHead: this.$mAssetsPath.iconHead,
				userBg: this.$mAssetsPath.userBg,	// 顶部背景装饰
				userOperationMenu: this.$mConstDataConfig.userOperationMenu,	// 用户操作菜单
			}
		},
		computed: {
			...mapState(['userInfo'])
		},
		methods: {
			// 操作
			tapOperation(e) {
				if(e) {
					this.$openPage(e)
				}
			},
			// 退出登录
			logout(){
				this.$https({
					url:"/logout",
					methods:"get",
					success:(res)=>{
						this.$store.commit("logout")
						uni.reLaunch({
								url: '/pages/login/login'
							});
					}
				})
			}
			
		},
		// #ifdef APP-PLUS
		onBackPress(e) {
			uni.showModal({
				content: '确定要退出程序？',
				success: res => {
					if(res.confirm) {
						// 退出当前应用，改方法只在App中生效
						plus.runtime.quit();
					}
				} 
			})
			return true;
		}
		// #endif
	}
</script>

<style lang="scss" scoped>
	// 顶部背景
	.user-top {
		width: 100%;
		height: 200px;
		top: 0;
	}
	
	.user-bg {
		position: absolute;
		left: 0;
		top: 0;
		width: 100vw;
		height: 60vw;
		opacity: 0.84;
	}
	
	// 用户信息
	.user-info {
		height: 240rpx;
		align-items: center;
		justify-content: space-between;
	}
	
	.user-name {
		font-weight: 600;
	}
	
	.user-phone {
		font-size: $uni-font-size-base;
		margin-top: $uni-spacing-col-sm;
	}
	
	.user-image {
		width: 120rpx;
		height: 120rpx;
		border-radius: $uni-border-radius-circle;
	}
	
	// 用户操作菜单
	.user-operation-menu {
		margin-top: 20rpx;
		font-size: $uni-font-size-base;
	}
	
	.user-operation-menu-item {
		height: 96rpx;
		align-items: center;
		justify-content: space-between;
		border-bottom: 2rpx solid rgba($color: $uni-border-color, $alpha: .3);
	}
	
	.left {
		align-items: center;
		
		.iconfont {
			font-size: 40rpx;
			margin-right: 20rpx;
		}
	}
	
	.user-operation-menu-item:last-child {
		border-bottom: none;
	}
	
	.iconfont {
		color: $uni-text-color-grey;
	}
	
	// new
	.logout-box{
		
		
		
	}
	.logout-btn{
		margin: 30rpx;
		border-radius: 20rpx;
		background-color: #fff;
	}
	
</style>
